package cn.jly.bigdata.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author lanyangji
 * @date 2019/11/28 15:17
 */
object Spark11_SequenceFile {

  def main(args: Array[String]): Unit = {

    val sc = new SparkContext(new SparkConf().setMaster("local[*]").setAppName("test-file"))

    val arrayRdd: RDD[(Int, Int)] = sc.makeRDD(Array((1, 2), (3, 4), (5,6)))

    arrayRdd.saveAsSequenceFile("out/seqFile")

    println("---读取--")

    val seq: RDD[(Int, Int)] = sc.sequenceFile[Int, Int]("out/seqFile")

    seq.foreach(println)

    sc.stop()
  }
}
